#ifndef PoLY_H
#define PoLY_H

#include <OpenGL/gl.h>

#include <vector>

#include "Vertex.h"
#include "Line.h"
#include "Defines.h"

namespace Y{

struct Vertex_tc{
	Vertex2f texCoord;
	Vertex4f color;
};

typedef std::vector< Vertex3f > Poly;
typedef std::vector< Vertex_tc > PolyData;

class ClippingPoly{
	
	public:
		
		ClippingPoly(): l(NULL) { }
		ClippingPoly( const Vertex3f& v0,const Vertex3f& v1,const Vertex3f& v2,const Vertex3f& v3 );
		ClippingPoly( Vertex3f *va, int s );
		ClippingPoly( const std::vector< Vertex3f >& vec );
		template <class VC>
		ClippingPoly( const std::vector< VC >& vec );

		std::vector < Line > l;
		Vertex3f center;
		int size () const { return l.size(); }
		
		void translate (float x, float y);
		void translate (const Vertex3f& v);
		
		void clipInclusively ( const Poly& r, std::vector < Poly >& ret ){ ret.push_back( clipInclusively(r) ); }
		Poly clipInclusively ( const Poly& r );
		void clipExclusively ( const Poly& passed, std::vector < Poly >& ret );
		
		template <class VC>
		std::vector< VC > clipInclusively ( const std::vector< VC >& r );
		template <class VC>
		void clipExclusively ( const std::vector<VC>& passed, std::vector < std::vector<VC> >& ret );
		
		bool sameSign ( float f, float f2 );
		bool sameSignX ( float f, float f2 );
		
		static bool deb;
};
	
#include "PolyTemplateImplimentation.h"

}
#endif